/**
 * 
 */
package dao;

import java.sql.SQLException;

import utils.Const;
import com.j256.ormlite.dao.Dao;
import database.DatabaseHelper;
import entity.Plan;
import entity.Tip;

/**
 * @author Hung
 *
 */
public class TipDAO {
	
	private Dao<Tip, Integer> dao = null;
	
	public TipDAO(DatabaseHelper helper) throws Exception {
		dao = helper.getTipDao();
		if (dao == null)
			throw new Exception(Const.NULL_DAO_ERROR);
	}
	
	public int createTip(Tip tip) throws SQLException {
		return dao.create(tip);
	}
	
	public int updateTip(Tip tip) throws SQLException {
		return dao.update(tip);
	}
	
	public int deleteTip(Tip tip) throws SQLException {
		return dao.delete(tip);
	}
	
	public Tip getTipById(int id) throws SQLException {
		return dao.queryForId(id);
	}
}
